#!/bin/bash


function build() {

	echo "真机 release 开始编译"

	xcodebuild -workspace SDKDemo/SDKDemo.xcworkspace -scheme SDKDemo -configuration Release -sdk iphoneos

	echo "真机 release 结束编译"

	echo "模拟器 release 开始编译"

	xcodebuild -workspace SDKDemo/SDKDemo.xcworkspace -scheme SDKDemo -configuration Release -sdk iphonesimulator

	echo "模拟器 release 结束编译"

}

function simRemoveArm64() {
	echo "模拟器移除arm64"

	lipo SDKDemo/DerivedData/SDKDemo/Build/Products/Release-iphonesimulator/SDKDemo.framework/SDKDemo -remove arm64 -output SDKDemo/DerivedData/SDKDemo/Build/Products/Release-iphonesimulator/SDKDemo.framework/SDKDemo

	echo "移除结束"
}

function merge() {

	echo "合并SDK"

	cp -r SDKDemo/DerivedData/SDKDemo/Build/Products/Release-iphonesimulator/SDKDemo.framework SDKDemo/DerivedData/SDKDemo/Build/Products/
	lipo -create SDKDemo/DerivedData/SDKDemo/Build/Products/Release-iphonesimulator/SDKDemo.framework/SDKDemo SDKDemo/DerivedData/SDKDemo/Build/Products/Release-iphoneos/SDKDemo.framework/SDKDemo -output SDKDemo/DerivedData/SDKDemo/Build/Products/SDKDemo.framework/SDKDemo

	echo "合并结束"

}

function verify() {

	echo "开始验证SDK支持的架构"

	lipo -info SDKDemo/DerivedData/SDKDemo/Build/Products/Release-iphonesimulator/SDKDemo.framework/SDKDemo
	lipo -info SDKDemo/DerivedData/SDKDemo/Build/Products/Release-iphoneos/SDKDemo.framework/SDKDemo
	lipo -info SDKDemo/DerivedData/SDKDemo/Build/Products/SDKDemo.framework/SDKDemo

	echo "验证完毕"

}

build
simRemoveArm64
merge
verify




